package day15.OneStageSystem;

public class NetPackage extends ServicePackage implements CallService,NetService,SendService{
    public NetPackage(double price){
        super.price = price;
    }
    //电话方法
    public int call(int minCount, MobileCard card) {
        card.setRealTalkTime(minCount+card.getRealTalkTime());
        int flag = card.getRealTalkTime();
        double beyond = flag * 0.2;
        if ((card.getMoney()-beyond)>0){
            card.setMoney(card.getMoney()-beyond);
            card.setConsumerAmount(card.getConsumerAmount()+beyond);
        }else {
            System.out.println("余额不足以支持使用此次使用,请充值!");
        }
        return 0;
    }

    //流量方法
    public int netPlay(int flow, MobileCard card) {
        card.setRealFlow(flow+card.getRealFlow());
        int flag = card.getRealFlow();
        if (flag>(1024*3)){
            double beyond = (flag-(1024*3))*0.1;
            if ((card.getMoney()-beyond)>0){
                card.setMoney(card.getMoney()-beyond);
                card.setConsumerAmount(card.getConsumerAmount()+beyond);
            }else {
                System.out.println("余额不足以支持使用此次使用,请充值!");
            }
        }
        return Math.max(((1024*3)-card.getRealFlow()),0);
    }
    //短信方法
    public int send(int count, MobileCard card) {
        card.setRealSMSCount(count+ card.getRealSMSCount());
        int flag = card.getRealSMSCount();
        double beyond = flag*0.1;
        if ((card.getMoney()-beyond)>0){
            card.setMoney(card.getMoney()-beyond);
            card.setConsumerAmount(card.getConsumerAmount()+beyond);
        }else {
            System.out.println("余额不足以支持使用此次使用,请充值!");
        }
        return 0;
    }

    //展示方法
    public void showInfo() {
        System.out.println("网虫套餐:每月通话时长0分钟,每月上网流量3GB,每月短信0条,套餐费用68元");
    }
}
